package com.example.demo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * 重点企业产值
 */
@Data
public class KeyEnterprisesProduct {

    /**
     * 序号
     */
    private int number;

    /**
     *单位名称
     */
    private String name;

    /**
     *本期当月
     */
    private double currentMonth;

    /**
     *本期累计
     */
    private double currentAccumulate;

    /**
     *同期累计
     */
    private double previousAccumulate;

    /**
     *累计同比
     */
    private double monthOnMothAccumulate;

    /**
     *归属集团
     */
    private String group;

    /**
     *归属法人
     */
    private String judicialPerson;

    /**
     * 构造函数
     * @param number
     * @param name
     * @param mKep
     */
    public KeyEnterprisesProduct(int number, String name, MinKeyEnterprisesProduct mKep) {
        this.number = number;
        this.name = name;
        this.currentMonth = mKep.getTotalCurrentMonth();
        this.currentAccumulate = mKep.getTotalCurrentAccumulate();
        this.previousAccumulate = mKep.getTotalPreviousAccumulate();

        double monthOnMonth = (mKep.getTotalCurrentAccumulate() - mKep.getTotalPreviousAccumulate())*100 / mKep.getTotalPreviousAccumulate();
        double value = new BigDecimal(monthOnMonth).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
        this.monthOnMothAccumulate = value;
    }

    public KeyEnterprisesProduct(String name, double currentMonth, double currentAccumulate, double previousAccumulate, double monthOnMothAccumulate, String group, String judicialPerson) {
        this.name = name;
        this.currentMonth = currentMonth;
        this.currentAccumulate = currentAccumulate;
        this.previousAccumulate = previousAccumulate;
        this.monthOnMothAccumulate = monthOnMothAccumulate;
        this.group = group;
        this.judicialPerson = judicialPerson;
    }
}
